﻿using System;
namespace Producers.Rr.Xtee.Riik.Ee.Producer.Rr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="RRTlnsynnitoetusparingkRequest", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RRTlnsynnitoetusparingkRequest))]
    public class RRTlnsynnitoetusparingkRequestSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IRRTlnsynnitoetusparingkRequest clazz;
        
        public RRTlnsynnitoetusparingkRequestSerializer(IRRTlnsynnitoetusparingkRequest clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("pocSalvestaNuppKuva");
            if (clazz.PocSalvestaNuppKuva!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PocSalvestaNuppKuva))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PocSalvestaNuppKuva");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("picKontaktaadress");
            if (clazz.PicKontaktaadress!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PicKontaktaadress))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PicKontaktaadress");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("picTelefon");
            if (clazz.PicTelefon!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PicTelefon))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PicTelefon");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("picSaajaEesnimi");
            if (clazz.PicSaajaEesnimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PicSaajaEesnimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PicSaajaEesnimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("picSaajaPerenimi");
            if (clazz.PicSaajaPerenimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PicSaajaPerenimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PicSaajaPerenimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("picSaajaIsikukood");
            if (clazz.PicSaajaIsikukood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PicSaajaIsikukood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PicSaajaIsikukood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("picSaajaKonto");
            if (clazz.PicSaajaKonto!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PicSaajaKonto))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PicSaajaKonto");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("picToendiNimi");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "base64Binary");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdBase64Binary(((byte[])(clazz.PicToendiNimi))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("picToendiLaiend");
            if (clazz.PicToendiLaiend!=null) {
                Writer.WriteTypeAttribute("http://producers.rr.xtee.riik.ee/producer/rr", "synnitoendi_formaat");
                Writer.WriteString(clazz.PicToendiLaiend.ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PicToendiLaiend");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="pocSalvestaNuppKuva") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsynnitoetusparingkRequest>pocSalvestaNuppKuva");
                }
                clazz.PocSalvestaNuppKuva = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pocSalvestaNuppKuva")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsynnitoetusparingkRequest>pocSalvestaNuppKuva", Reader.LocalName);
            }
            if (Reader.LocalName=="picKontaktaadress") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsynnitoetusparingkRequest>picKontaktaadress");
                }
                clazz.PicKontaktaadress = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("picKontaktaadress")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsynnitoetusparingkRequest>picKontaktaadress", Reader.LocalName);
            }
            if (Reader.LocalName=="picTelefon") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsynnitoetusparingkRequest>picTelefon");
                }
                clazz.PicTelefon = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("picTelefon")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsynnitoetusparingkRequest>picTelefon", Reader.LocalName);
            }
            if (Reader.LocalName=="picSaajaEesnimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsynnitoetusparingkRequest>picSaajaEesnimi");
                }
                clazz.PicSaajaEesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("picSaajaEesnimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsynnitoetusparingkRequest>picSaajaEesnimi", Reader.LocalName);
            }
            if (Reader.LocalName=="picSaajaPerenimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsynnitoetusparingkRequest>picSaajaPerenimi");
                }
                clazz.PicSaajaPerenimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("picSaajaPerenimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsynnitoetusparingkRequest>picSaajaPerenimi", Reader.LocalName);
            }
            if (Reader.LocalName=="picSaajaIsikukood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsynnitoetusparingkRequest>picSaajaIsikukood");
                }
                clazz.PicSaajaIsikukood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("picSaajaIsikukood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsynnitoetusparingkRequest>picSaajaIsikukood", Reader.LocalName);
            }
            if (Reader.LocalName=="picSaajaKonto") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsynnitoetusparingkRequest>picSaajaKonto");
                }
                clazz.PicSaajaKonto = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("picSaajaKonto")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsynnitoetusparingkRequest>picSaajaKonto", Reader.LocalName);
            }
            if (Reader.LocalName=="picToendiNimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsynnitoetusparingkRequest>picToendiNimi");
                }
                clazz.PicToendiNimi = new global::Xtee.Core.Schema.XsdBase64Binary(Reader.ReadElementString("picToendiNimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsynnitoetusparingkRequest>picToendiNimi", Reader.LocalName);
            }
            if (Reader.LocalName=="picToendiLaiend") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsynnitoetusparingkRequest>picToendiLaiend");
                }
                clazz.PicToendiLaiend = new global::Producers.Rr.Xtee.Riik.Ee.Producer.Rr.SynnitoendiFormaat(Reader.ReadElementString("picToendiLaiend"));
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsynnitoetusparingkRequest>picToendiLaiend", Reader.LocalName);
            }
        }
    }
}
